<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  String studentName = (String) request.getAttribute("studentName");
  String classic = (String) request.getAttribute("classic");

  // 空值保护：若classic为null，跳转到错误页面
  if (classic == null) {
    response.sendRedirect("error.jsp");
    return;
  }

  String classicName = "";
  switch (classic) {
    case "lunyu":
      classicName = "《论语》";
      break;
    case "daodejing":
      classicName = "《道德经》";
      break;
    case "tangshi":
      classicName = "《唐诗三百首》";
      break;
    default:
      classicName = "未知经典";
  }
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>电子荣誉卡</title>
  <style>
    .certificate {
      width: 600px;
      margin: 50px auto;
      padding: 30px;
      border: 5px solid #8B4513;
      text-align: center;
      background-color: #FFF8DC;
    }
    .title {
      color: #8B0000;
      font-size: 24px;
      font-weight: bold;
    }
    .content {
      margin: 30px 0;
      font-size: 18px;
    }
    .signature {
      margin-top: 50px;
      font-style: italic;
    }
  </style>
</head>
<body>
<div class="certificate">
  <div class="title">电子荣誉证书</div>
  <div class="content">
    <p>兹授予 <strong><%= studentName == null ? "未知姓名" : studentName %></strong> 同学</p>
    <p>完成 <strong><%= classicName %></strong> 经典诵读任务</p>
    <p>特发此证，以资鼓励！</p>
  </div>
  <div class="signature">
    经典诵读系统<br>
    <%= new java.util.Date().toLocaleString() %>
  </div>
</div>
</body>
</html>
